import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description: 测试去重  // 类说明，在创建类时要填写
 * @ClassName: testCompara    // 类名，会自动填充
 * @Author: wangtai          // 创建者
 * @Date: 2021/3/1 15:59   // 时间
 * @Version: 1.0     // 版本
 */

public class testCompara {
    public static void main(String[] args) {
        List<Student> oldStudents = new ArrayList<>();

        Student student1 = new Student();

        student1.setOnlyKey("123");
        student1.setClassName("电子");
        oldStudents.add(student1);

        Student student2 = new Student();
        student2.setOnlyKey("123");
        student2.setClassName("电子");
        oldStudents.add(student2);

        Student student3 = new Student();
        student3.setOnlyKey("123444");
        student3.setClassName("机械");
        oldStudents.add(student3);
        Student student4 = new Student();
        student4.setOnlyKey("1234");
        student4.setClassName("自动化");
        oldStudents.add(student4);

        Student student5 = new Student();
        student5.setOnlyKey("12322");
        student5.setClassName("电子");
        oldStudents.add(student5);

        List<Student> sList = new ArrayList<>();
        sList.stream().filter(stu->stu.getOnlyKey().equals("1")).collect(Collectors.toList());
        System.out.println(sList.size());
    }

}
